package ccy.ccykills;

import ccy.ccykills.playerdata.PlayerData;
import ccy.ccylibrary.plugin.CcyPlugin;
import ccy.ccykills.config.CcyConfig;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;

public class CcyKills extends CcyPlugin {

    @Override
    public void PluginEnable() {
        Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> CcyConfig.config.updateRank(), 0L, (long)CcyConfig.config.RankTime * 20L);
    }

    @Override
    public void PluginDisable() {
        super.PluginDisable();
        CcyConfig.config.playerNumMap.forEach((uid, kill) -> {
            Player player = Bukkit.getPlayer(uid);
            if (player != null && player.isOnline() && kill.isB()) {
                (new PlayerData(player)).setNum(kill.getValue());
            }

        });
    }

    @Override
    public Object MainClass() {
        return this;
    }

    @Override
    public String pluginName() {
        return "杀敌数系统";
    }
}
